package util;

import common.Course;
import common.Select;
import common.Topic;
import common.User;
import controller.MainController;
import controller.TeacherCourseController;
import javafx.application.Platform;

import java.util.HashMap;
import java.util.Vector;

public class FlushCourse {
    public static HashMap<String,Vector<User>> studentMap=new HashMap<>();
    public static HashMap<String,Vector<Select>> selectMap=new HashMap<>();
    public static HashMap<String,Vector<Topic>> topicMap=new HashMap<>();
    public static HashMap<String,Course> teachMap=new HashMap<>();
    public static void Flush(Vector<Course> teach,Vector<Course> learn){
        studentMap.clear();
        selectMap.clear();
        Platform.runLater(() -> {
            MainController.courses1.clear();
            if(teach!=null) {
                for (int i = 0; i < teach.size(); i++) {
                        MainController.courses1.add(teach.get(i));
                        studentMap.put(teach.get(i).getId(),teach.get(i).getStudent());
                        selectMap.put(teach.get(i).getId(),teach.get(i).getSelectTask());
                        topicMap.put(teach.get(i).getId(),teach.get(i).getTopicTask());
                        teachMap.put(teach.get(i).getId(),teach.get(i));
                    }
                }
            MainController.courses2.clear();
            if(learn!=null){
                for(int i=0;i<learn.size();i++){
                    MainController.courses2.add(learn.get(i));
                    selectMap2.put(learn.get(i).getId(),learn.get(i).getSelectTask());
                    studentMap2.put(learn.get(i).getId(),learn.get(i).getStudent());
                    topicMap2.put(learn.get(i).getId(),learn.get(i).getTopicTask());
                }
            }
        });
    }
    public static HashMap<String,Vector<Select>> selectMap2=new HashMap<>();
    public static HashMap<String,Vector<User>> studentMap2=new HashMap<>();
    public static HashMap<String,Vector<Topic>> topicMap2=new HashMap<>();
}
